
#import "UIImage+Pyw.h"
#import "PywResourceUtils.h"

@implementation UIImage (Pyw)

+ (UIImage *)imageWithName:(NSString *)imageName {
    if (IS_IPHONE_6P || IS_IPAD) {
        NSString *newName = [imageName stringByAppendingString:@"_pad"];
        UIImage *image = [[PywResourceUtils manger] image:newName];
        if (image == nil) { // 没有_pad后缀的图片
            image = [[PywResourceUtils manger] image:imageName];;
        }
        return image;
    }
    
    return [[PywResourceUtils manger] image:imageName];
}

+ (instancetype)resizableImageWithName:(NSString *)name leftRatio:(CGFloat)leftRatio topRatio:(CGFloat)topRatio
{
    UIImage *image = [[PywResourceUtils manger] image:name];
    CGSize size = image.size;
    
    image = [image stretchableImageWithLeftCapWidth:size.width*leftRatio topCapHeight:size.height*topRatio];
    
    return image;
}

+ (instancetype)resizableImageWithName:(NSString *)name
{
    return [self resizableImageWithName:name leftRatio:0.5 topRatio:0.5];
}

@end
